package com.kethink.clsssify.threadtest.threadPoolTest;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolTest {

    public static void main(String[] args) {
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
                1,2,3, TimeUnit.SECONDS,new LinkedBlockingDeque<Runnable>(3));
        poolExecutor.execute(new TestTread());

        poolExecutor.execute(new TestTread());
        poolExecutor.execute(new TestTread());
        poolExecutor.execute(new TestTread());

        poolExecutor.execute(new TestTread());

        try {
//            Thread.sleep(15000);
            poolExecutor.execute(new TestTread());
        } catch (Exception e) {
            e.printStackTrace();
        }


        poolExecutor.shutdown();
    }
}

class TestTread implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
